package com.ea.eadp.nexus.test.workflow.pc.register;

import org.openqa.selenium.WebDriver;

import com.ea.eadp.nexus.test.common.TestUtil;
import com.ea.eadp.nexus.test.pageDefinition.pc.CreateUnderageUserPage;
import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;

public class CreateUnderageUserWorkflowElement extends WorkflowElement {
    
    protected CreateUnderageUserPage page;
    
    public CreateUnderageUserWorkflowElement(
        WebDriver driver, WorkflowElementArgument args
    ) {
        super(driver, args);
        page = new CreateUnderageUserPage(driver);
    }
    
    @Override
    public void init() {
        super.init();
        page.initPage();
    }
    
    @Override
    public void doAction() {
        log.info("Set origin ID = " + args.originId);
        page.txt_originId.sendKeys(args.originId);
        
        log.info("Set parent email = " + args.parentEmail);
        page.txt_parentEmail.sendKeys(args.parentEmail);
        
        log.info("Set password = " + args.password);
        page.txt_password.sendKeys(args.password);
        page.txt_confirmPassword.sendKeys(args.password);
        
        String captcha = TestUtil.getRandomString();
        log.info("Set captcha = " + captcha);
        page.txt_captcha.sendKeys(captcha);
        
        page.check_AcceptTOS.click();
    }
    
    @Override
    public void moveNext() {
        page.btn_submit.click();
    }
    
}
